﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CollBrowser
{
    /// <summary>
    /// 采集用的状态列
    /// </summary>
    public class CollectionState
    {
        private string _目标地址 = "";

        public string 目标地址
        {
            get { return _目标地址; }
            set { _目标地址 = value; }
        }

        private string _当前状态 = "准备中";

        public string 当前状态
        {
            get { return _当前状态; }
            set { _当前状态 = value; }
        }

        /// <summary>
        /// 获取的结果 HTML
        /// </summary>
        private string _结果 = "";

        public string 结果
        {
            get { return _结果; }
            set { _结果 = value; }
        }

        private System.Windows.Forms.WebBrowser browser = null;

        public System.Windows.Forms.WebBrowser Browser
        {
            get
            {
                if (browser == null)
                {
                    browser = new System.Windows.Forms.WebBrowser()
                       {
                           ScriptErrorsSuppressed = false,

                       };
                    browser.Disposed += new EventHandler(browser_Disposed);
                }

                return browser;
            }
        }

        /// <summary>
        /// 方法释放组件时发生 的通知
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void browser_Disposed(object sender, EventArgs e)
        {
            Loading = false;
            if (当前状态.Contains("正在处理"))
            {
                当前状态 = "出错,无法继续加载文档";
            }
        }

        /// <summary>
        /// 是不是正在加载文件
        /// </summary>
        public bool Loading = false;
    }
}
